//
// Created by shenbin on 2022/4/21.
// https://leetcode-cn.com/problems/two-sum/
//

#ifndef ALGORITHM_TRAINNING_C03_LC1_H
#define ALGORITHM_TRAINNING_C03_LC1_H
#include <vector>
#include <unordered_map>
using namespace std;
class LeetCode1{
public:
    vector<int> twoSum(vector<int>& nums, int target){
        for(i=0; i<nums.size(); i++)
        {
            if(h.find(target-nums[i]) != h.end())
            {
                return {h[target-nums[i]], i};
            }
            h[nums[i]] = i;
        }
        return {};

    }
private:
    unordered_map<int, int> h;
};

#endif //ALGORITHM_TRAINNING_C03_LC1_H
